package com.cblz.bd.server.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * {@code @Name:} BcryptUtil
 * {@code @Description: } 密码加密工具类
 * {@code @Author:} by yanjieping
 * {@code @CreateDate:} 2022/11/9 - 周三
 */
public class BcryptUtil {

    /**
     * 密码加密
     *
     * @param content 内容
     * @return
     */
    public static String encrypt(String content) {
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        return bCryptPasswordEncoder.encode(content);
    }

    /**
     * 解密对比
     *
     * @param content        未加密内容
     * @param encryptContent 加密内容
     * @return
     */
    public static boolean decrypt(String content, String encryptContent) {
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        return bCryptPasswordEncoder.matches(content, encryptContent);

    }
}
